import App from './App'
import store from './store'
// import  {add_group} from '../common/uniCloudApi.js'
	import  * as UniCloudApi from './common/uniCloudApi.js';
	import  * as publicApi from './common/publicApi.js';

// main.js
import uviewPlus from 'uview-plus'

// #ifndef VUE3
import Vue from 'vue'
var userInfo = uni.getStorageSync('userInfo')
	var isLogin = userInfo.openId != null? true:false

Vue.config.productionTip = false
Vue.prototype.$store = store
Vue.prototype.$adpid = "wx7da5a2c25fd4157c"
Vue.prototype.$uniCloudApi = UniCloudApi // 将其添加到Vue原型链
Vue.prototype.$userInfo = userInfo // 
Vue.prototype.$isLogin = isLogin // 
// Vue.use(uView);


Vue.prototype.$backgroundAudioData = {
	playing: false,
	playTime: 0,
	formatedPlayTime: '00:00:00'
}
App.mpType = 'app'
const app = new Vue({
	store,
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
var userInfo = uni.getStorageSync('userInfo')
	var isLogin = userInfo.openId != null? true:false
   app.use(store)
	app.config.globalProperties.$adpid = "wx7da5a2c25fd4157c"
	app.config.globalProperties.$uniCloudApi = UniCloudApi // 将其添加到Vue原型链
	app.config.globalProperties.$userInfo = userInfo// 将其添加到Vue原型链
	app.config.globalProperties.$isLogin = isLogin // 将其添加到Vue原型链
	app.config.globalProperties.$publicApi = publicApi // 将其添加到Vue原型链
	app.config.globalProperties.$appConfigureData = null;//配置信息
	app.config.globalProperties.$adcount = 0;//看广告次数
	
	app.config.globalProperties.$backgroundAudioData = {
		playing: false,
		playTime: 0,
		formatedPlayTime: '00:00:00'
	}
	app.config.globalProperties.$setUserInfo = function(userData) {
		app.config.globalProperties.$userInfo = null;
	    app.config.globalProperties.$userInfo = userData;
		app.config.globalProperties.$isLogin = true;
		console.log('设置登录数据22====',app.config.globalProperties.$userInfo);
		console.log('设置登录数据33====',userData);
		
	};
	app.config.globalProperties.$removeUserInfo = function() {
		console.log('删除登录数据====');
	    app.config.globalProperties.$userInfo = null;
		app.config.globalProperties.$isLogin = false;
		
		console.log('删除登录数据22====',app.config.globalProperties.$userInfo);
	};
	app.config.globalProperties.$encodeJson = function(json) {
	  return	encodeURIComponent(JSON.stringify(json));
	};
	app.config.globalProperties.$decodeJson = function(jsonStr) {
	  return	JSON.parse(decodeURIComponent(jsonStr));
	};
	app.config.globalProperties.$showToast = function(text) {
	  uni.showToast({
	  	title:text,
		icon: 'none'
	  })
	};
	app.config.globalProperties.$saveAppConfigureData = function(data) {
	  app.config.globalProperties.$appConfigureData = data
	};
	
	app.use(uviewPlus)
	
	return {
		app
	}
}
// #endif
